/*    */ package handling.channel;
/*    */ 
/*    */ import com.alibaba.druid.pool.DruidPooledConnection;
/*    */ import database.DatabaseConnection;
/*    */ import java.sql.PreparedStatement;
/*    */ import java.sql.ResultSet;
/*    */ import java.sql.SQLException;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DojoRankingsData
/*    */ {
/* 16 */   private static final DojoRankingsData instance = new DojoRankingsData();
/*    */   private static final int limit = 25;
/* 18 */   public final String[] names = new String[25];
/* 19 */   public final long[] times = new long[25];
/* 20 */   public final int[] ranks = new int[25];
/* 21 */   public int totalCharacters = 0;
/*    */ 
/*    */ 
/*    */ 
/*    */   
/*    */   public static DojoRankingsData getInstance() {
/* 27 */     return instance;
/*    */   }
/*    */   
/*    */   public static DojoRankingsData loadLeaderboard() {
/* 31 */     DojoRankingsData ret = new DojoRankingsData();
/* 32 */     try (DruidPooledConnection con = DatabaseConnection.getInstance().getConnection()) {
/* 33 */       PreparedStatement ps = con.prepareStatement("SELECT `name`, `time` FROM `dojorankings` ORDER BY `time` ASC LIMIT 25");
/* 34 */       ResultSet rs = ps.executeQuery();
/*    */       
/* 36 */       int i = 0;
/* 37 */       while (rs.next()) {
/* 38 */         if (rs.getInt("time") != 0) {
/*    */           
/* 40 */           ret.ranks[i] = i + 1;
/* 41 */           ret.names[i] = rs.getString("name");
/* 42 */           ret.times[i] = rs.getInt("time");
/*    */           
/* 44 */           ret.totalCharacters++;
/* 45 */           i++;
/*    */         } 
/*    */       } 
/* 48 */     } catch (SQLException ex) {
/* 49 */       ex.printStackTrace();
/*    */     } 
/* 51 */     return ret;
/*    */   }
/*    */ }


/* Location:              C:\PGX\Server.jar!\handling\channel\DojoRankingsData.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */